/*
 Navicat Premium Dump SQL

 Source Server         : 127.0.0.1
 Source Server Type    : MySQL
 Source Server Version : 50744 (5.7.44)
 Source Host           : 127.0.0.1:3306
 Source Schema         : smart_community

 Target Server Type    : MySQL
 Target Server Version : 50744 (5.7.44)
 File Encoding         : 65001

 Date: 14/09/2025 22:39:37
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for sc_zone
-- ----------------------------
DROP TABLE IF EXISTS `sc_zone`;
CREATE TABLE `sc_zone` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '分区ID',
  `zone_name` varchar(100) NOT NULL COMMENT '分区名称',
  `zone_code` varchar(50) NOT NULL COMMENT '分区编码',
  `community_id` bigint(20) NOT NULL COMMENT '所属社区ID',
  `property_company_id` bigint(20) NOT NULL COMMENT '所属物业公司ID',
  `zone_type` varchar(50) DEFAULT 'residential' COMMENT '分区类型：residential-住宅区，commercial-商业区，office-办公区，parking-停车区，activity-活动区',
  `zone_color` varchar(20) DEFAULT '#409EFF' COMMENT '分区颜色标识',
  `zone_description` text COMMENT '分区描述',
  `zone_boundary` longtext COMMENT '分区边界坐标数据(JSON格式)',
  `zone_center_x` decimal(10,2) DEFAULT NULL COMMENT '分区中心X坐标',
  `zone_center_y` decimal(10,2) DEFAULT NULL COMMENT '分区中心Y坐标',
  `zone_area` decimal(10,2) DEFAULT NULL COMMENT '分区面积(平方米)',
  `building_count` int(11) DEFAULT '0' COMMENT '包含楼栋数量',
  `household_count` int(11) DEFAULT '0' COMMENT '包含住户数量',
  `status` tinyint(1) DEFAULT '1' COMMENT '状态：1-启用，0-禁用',
  `sort_order` int(11) DEFAULT '0' COMMENT '排序顺序',
  `create_time` datetime DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
  `create_by` bigint(20) DEFAULT NULL COMMENT '创建用户ID',
  `update_by` bigint(20) DEFAULT NULL COMMENT '更新用户ID',
  `deleted` tinyint(1) DEFAULT '0' COMMENT '是否删除：1-已删除，0-未删除',
  `version` int(11) DEFAULT '1' COMMENT '版本号',
  `remark` text CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci COMMENT '备注',
  PRIMARY KEY (`id`),
  UNIQUE KEY `uk_zone_code` (`community_id`,`zone_code`,`zone_type`) USING BTREE,
  KEY `idx_community_id` (`community_id`),
  KEY `idx_property_company_id` (`property_company_id`),
  KEY `idx_zone_type` (`zone_type`),
  KEY `idx_status` (`status`),
  KEY `idx_create_time` (`create_time`),
  KEY `idx_zone_community_property` (`community_id`,`property_company_id`,`status`),
  KEY `idx_zone_type_status` (`zone_type`,`status`,`sort_order`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COMMENT='社区分区表';

-- ----------------------------
-- Records of sc_zone
-- ----------------------------
BEGIN;
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (1, '东区', 'ZONE_001', 1, 1, 'residential', '#409EFF', '社区东部住宅区域，包含1-4号楼', NULL, NULL, NULL, NULL, 4, 160, 1, 1, '2025-08-15 17:16:24', '2025-08-15 17:16:24', 1, NULL, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (2, '南区', 'ZONE_002', 1, 1, 'residential', '#67C23A', '社区南部住宅区域，包含5-8号楼', NULL, NULL, NULL, NULL, 4, 160, 1, 2, '2025-08-15 17:16:24', '2025-08-15 17:16:24', 1, NULL, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (3, '西区', 'ZONE_003', 1, 1, 'residential', '#E6A23C', '社区西部住宅区域，包含9-12号楼', NULL, NULL, NULL, NULL, 4, 160, 1, 3, '2025-08-15 17:16:24', '2025-08-15 17:16:24', 1, NULL, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (4, '商业区', 'ZONE_004', 1, 1, 'commercial', '#F56C6C', '社区商业区域，包含商业楼和办公楼', NULL, NULL, NULL, NULL, 3, 0, 1, 4, '2025-08-15 17:16:24', '2025-08-15 17:16:24', 1, NULL, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (5, '东区', 'DONGQU', 20, 1014, 'residential', 'rgb(156, 39, 176)', '东区', NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-08-17 23:51:35', '2025-08-17 23:51:35', 35, 35, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (6, '南区', 'NANQU', 20, 1014, 'residential', 'rgb(103, 194, 58)', '南区', NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-08-18 09:33:31', '2025-08-18 09:33:31', 35, 35, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (7, '东区', 'DONGQU', 21, 1010, 'commercial', '#409EFF', NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-08-18 22:29:50', '2025-08-18 22:29:50', 34, 34, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (8, '南区', 'NANQU', 21, 1010, 'residential', '#409EFF', NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-08-19 00:58:27', '2025-08-19 00:58:27', 34, 34, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (9, '西区', 'XIQU', 21, 1010, 'commercial', 'rgb(255, 152, 0)', NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-08-25 10:29:40', '2025-08-25 10:29:40', 24, 24, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (10, '南区', 'NANQU', 23, 1015, 'residential', '#409EFF', NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-09-02 11:01:08', '2025-09-02 11:01:08', 42, 42, 0, 1, NULL);
INSERT INTO `sc_zone` (`id`, `zone_name`, `zone_code`, `community_id`, `property_company_id`, `zone_type`, `zone_color`, `zone_description`, `zone_boundary`, `zone_center_x`, `zone_center_y`, `zone_area`, `building_count`, `household_count`, `status`, `sort_order`, `create_time`, `update_time`, `create_by`, `update_by`, `deleted`, `version`, `remark`) VALUES (11, '学校区', 'XUEXIAOQU', 23, 1015, 'office', '#409EFF', NULL, NULL, NULL, NULL, NULL, 0, 0, 1, 0, '2025-09-02 11:03:15', '2025-09-02 11:03:15', 42, 42, 0, 1, NULL);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
